﻿using System.Collections.Generic;
using Campari.Software;
using AspNetInfo.Core;
using System.Web;
using System.Data;

namespace AspNetInfo.Detectors
{
    public class IisDetector : IDetector
    {
        public DataTable Detect(EnvironmentPermissions permissions)
        {
            var dt = DetectorHelper.MakeResultTable();
            if (permissions.TrustLevel > AspNetHostingPermissionLevel.Medium)
            {
                dt.Rows.Add("IIS4", InternetInformationServicesDetection.IsInstalled(InternetInformationServicesVersion.IIS4).ToString());
                dt.Rows.Add("IIS5", InternetInformationServicesDetection.IsInstalled(InternetInformationServicesVersion.IIS5).ToString());
                dt.Rows.Add("IIS51", InternetInformationServicesDetection.IsInstalled(InternetInformationServicesVersion.IIS51).ToString());
                dt.Rows.Add("IIS6", InternetInformationServicesDetection.IsInstalled(InternetInformationServicesVersion.IIS6).ToString());
                dt.Rows.Add("IIS7", InternetInformationServicesDetection.IsInstalled(InternetInformationServicesVersion.IIS7).ToString());
                dt.Rows.Add("IIS75", InternetInformationServicesDetection.IsInstalled(InternetInformationServicesVersion.IIS75).ToString());
                dt.Rows.Add("IIS8", InternetInformationServicesDetection.IsInstalled(InternetInformationServicesVersion.IIS8).ToString());
            }
            return dt;
        }
        public string Name
        {
            get { return "IIS"; }
        }

        public string Description
        {
            get { return "Determines if the specified version of Internet Information Services (IIS) is installed on the local computer."; }
        }

        public string TabName
        {
            get { return "ASP.NET"; }
        }
    }
}
